<!DOCTYPE html>
<html>
<head>
<title>商盟统统付标准收银台接口</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php



$mer_no = $_POST ["mer_no"];
date_default_timezone_set ( "Asia/Shanghai" );
$timestamp = date ( 'YmdHis' );
$terminal_type = $_POST ["terminal_type"];
$url = 'https://test.sumpay.cn/entrance/gateway.htm';
$domain = $_POST ["domain"];
$bill_date = $_POST ["bill_date"];
$part_num = $_POST ["part_num"];

$service = 'fosun.sumpay.api.checking.checkbills';

$parameters = [ 
		'app_id' => $mer_no,
		'terminal_type' => $terminal_type,
		'version' => '1.0',
		'service' => $service,
		'timestamp' => $timestamp,
		'mer_no' => $mer_no,
		'format' => 'JSON',
		'bill_date' => $bill_date,
		'part_num' => $part_num
];

$encrypted_fields = array ();
$charset_change_fields = array (
		"terminal_info"
);
$special_fields = array (
		"terminal_info"
);
$json_array_fields = array();
$defaultCharset = 'UTF-8';

include '../tools/SumpayService.php';
$res = execute ( $url, 'UTF-8', $parameters, "../cer/yixuntiankong.pfx", "sumpay", "../cer/dev_pub.pem", $domain, $charset_change_fields, $encrypted_fields, $special_fields, $json_array_fields, $defaultCharset );
if($res['resp_code'] == '000000'){
	// 表示处理成功，可以处理后续业务
	if(substr ( $service, 0, 20 ) == 'fosun.sumpay.cashier'){
		$returnUrl = $res['redirect_url'];
		echo <<< HTML
<form hidden=true method=post action=$returnUrl>
<input hidden=true type=submit value=ok>
</form>
<script>
document.forms[0].submit();
</script>
HTML;
	}else{
		// 这步只是展示成功的响应，具体业务商户自己处理
		echo json_encode($res);
	}
}else{
	echo json_encode($res);
}

?>

</body>
</html>
